Page({
  data: {
    addresses: []
  },
  
  onLoad() {
    this.loadAddresses()
  },
  
  onShow() {
    this.loadAddresses()
  },
  
  loadAddresses() {
    // 从本地存储加载地址列表
    const addresses = wx.getStorageSync('addresses') || []
    this.setData({ addresses })
  },
  
  addAddress() {
    wx.navigateTo({
      url: '/pages/address-edit/address-edit'
    })
  },
  
  editAddress(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/address-edit/address-edit?id=${id}`
    })
  }
})
